package com.huawei.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @Author LF
 * projectName:vue-cli
 * description:
 * time:2025-04-27 23:38
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements UserDetails {
    /**
     * 用户编号
     */
    private Integer id;

    /**
     * 登陆名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 真实姓名
     */
    private String realname;

    /**
     * 账户是否过期1正常0过期
     */
    private String accountExpired;

    /**
     * 账户是否锁家1正常0锁定
     */
    private String accountLocked;

    /**
     * 密码是否过期1正常0过期
     */
    private String credentialsExpired;

    /**
     * 账户是否彬1启用0禁用
     */
    private String enabled;

    @Override
    @JsonIgnore
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonExpired() {
        return this.accountExpired.equals("1");
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonLocked() {
        return this.accountLocked.equals("1");
    }

    @Override
    @JsonIgnore
    public boolean isCredentialsNonExpired() {
        return this.credentialsExpired.equals("1");
    }

    @Override
    @JsonIgnore
    public boolean isEnabled() {
        return this.enabled.equals("1");
    }
}